package com.empsys.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author wzm
 * @create 2023-12-13 15:44
 * project_name:web2310
 * @Description
 */
//使用拦截器完成登录验证
//@Component //交给ioc管理
public class OldoginChekInterceptor implements HandlerInterceptor {

    //控制器目标方法执行前执行  返回boolean =true 放行  false 拦截不放行
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("prehandle.....");
        return true;
    }

    //控制方法执行以后会自动执行的方法
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("postHanle....");
    }

    //springBoot中控制跳转到页面，视图渲染完毕后执行  最后执行
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
      /*  System.out.println("视图渲染后执行");*/
    }
}
